﻿<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:Avanade="urn:Avanade" xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'>
  <xsl:template match="/">
      <xsl:choose>
        
        <xsl:when test="//GroupByCategory = 'True'">
          <table width="100%" border="0" cellspacing="0" cellpadding="0" summary="Webpart LIENS">
            <xsl:for-each select="xml/rs:data/Category">
            <tr>
              <td style="padding-top:10px;font-size:10px;">
                <div style="font-size:11px;color:#e02c84;font-weight:bold;">
                  <xsl:value-of select="Avanade:FormatTitle(current()/@title)" />
                </div>
              </td>
            </tr>
            <xsl:for-each select="z:row">
              <xsl:sort select="current()/@ows_Ordre"/>
              <xsl:sort select="current()/@ows_Created" order="descending" />
              <tr>
                <td>
                  <xsl:if test="current()/@ows_URL != ', '">
                    <a style="color:#304500;" target="_blank">
                      <xsl:attribute name="href">
                        <xsl:value-of select="Avanade:FormatLink(current()/@ows_URL)" />
                      </xsl:attribute>
                      <xsl:value-of select="Avanade:GetDescription(current()/@ows_URL)" />
                    </a>
                  </xsl:if>
                </td>
              </tr>
            </xsl:for-each>
          </xsl:for-each>
          </table>
        </xsl:when>

        <xsl:otherwise>
          <table class="ms-summarycustombody" style="MARGIN-BOTTOM: 5px" cellSpacing="0" cellPadding="0" border="0" summary="Webpart LIENS">
          <xsl:for-each select="xml/rs:data/z:row[not(@ows_URL=preceding-sibling::z:row/@ows_URL)]">
            <xsl:sort select="current()/@ows_Ordre"/>
			<xsl:sort select="current()/@ows_Created" order="descending" />
            <tr>
              <td class="ms-vb" style="padding-bottom: 5px">
                <img alt="" src="/_layouts/images/square.gif" />&amp;nbsp;
              </td>
              <td class="ms-vb" style="padding-left: 5px; padding-bottom: 5px">
                <xsl:if test="current()/@ows_URL != ', '">
                  <a style="color:#304500;" target="_blank">
                    <xsl:attribute name="href">
                      <xsl:value-of select="Avanade:FormatLink(current()/@ows_URL)" />
                    </xsl:attribute>
                    <xsl:value-of select="Avanade:GetDescription(current()/@ows_URL)" />
                  </a>
                </xsl:if>
              </td>
            </tr>
          </xsl:for-each>
          </table>
        </xsl:otherwise>
        
      </xsl:choose>
  </xsl:template>
</xsl:stylesheet>